Memory is one of the critical resources for any computing system and plays an essential role in performance, scalability, and availability of applications/programs being developed. In scenarios where memory is not handled properly, it might lead to many bugs and major performance issues. Such scenarios may be encountered when an application is using Central Processing Unit (CPU) excessively, when ‘OutOfMemory’ exception is thrown, and when a process is using too much memory for no evident reason. Thus, the need for memory management arises; accordingly, effective memory management has been an important factor in the field of computing system. The task of managing memory involves allocating memory to programs when requested and de-allocating the memory for reuse when the programs no longer require the allocated memory. However, de-allocation may not always occur.
There exist a number of memory management problems that are common to programs written in various programming languages. Some examples of the memory management problems are dangling pointers, misassignment, memory leaks, and array bound violations. One of the most common forms of memory management problems is memory leak. Memory leak is a type of unconscious memory consumption by a computer program, where the program is unable to release the memory it has acquired. This causes the program to consume memory when no longer needed and this simultaneously affects the available memory for other computer programs. Eventually, slow down of the computing system and crashing of the computer applications can occur.
Over the years, the problem of memory leak has plagued programmers who write programs in different programming languages. Specially, with respect to languages having manual memory management, such as C and C++, writing large programs with minimal memory leaks can be challenging. Programs written in these languages often have a large number of memory leaks that can be difficult to trace.
There exist a number of methods and systems for detecting memory leaks in a program. However, these existing methods and systems focus on detecting the memory leaks manually; thus, a lot of effort and time is required by the programmers. Further, a number of tools are available in the market for detecting the memory leaks, but these tools specially focus on detecting the memory leaks at run-time (i.e., after developing the program). Thus, a lot of rework for modifying the program is required once the memory leaks are detected. Additionally, the above mentioned solutions are not capable of highlighting variables or functions causing the memory leaks.
In view of the foregoing discussion, there is a need for an automated method and a system for detecting memory leaks in a program. An automated approach of detecting the memory leaks saves a lot of effort and time required by programmers. This further enhances the capability of the programmers to detect the memory leaks with ease. Further, there also lies a need to detect the memory leaks at the time of developing a program so that a lot of rework required at later stages is avoided. Moreover, there also exists a need for pinpointing variables or functions causing the memory leaks, thereby helping the programmers to easily track the memory leaks and fix it accordingly.